﻿<%@ Page Title="List of Retreats" Language="C#" AutoEventWireup="True" CodeBehind="Listing.aspx.cs" MasterPageFile="/PageTemplate.Master" Inherits="RMS.Pages.Listing" %>
<%@ Import Namespace="System.Web.Routing" %>

<asp:Content ID="Content1" ContentPlaceHolderID="BodyContent" runat="server">
    
    <!-- Listing Web Form allows for browsing and adding Retreats to the cart. -->   
    <div>
        <asp:Repeater ID="Repeater1" ItemType="RMS.Models.Retreat" SelectMethod="GetRetreats" runat="server">
            
            <ItemTemplate>
                <div class="item">
                    <h3><%# Item.Ret_Title %></h3>
                    <p></p>
                                        
                    <table class="categoryTable"> <!-- Category Section -->
                    <tr>
                        <td><b>Categories:</b></td>
                        <td><%# Item.Ret_Main_Category %></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td> <%# Item.Ret_Category_Two %></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td> <%# Item.Ret_Category_Three %></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td> <%# Item.Ret_Category_Four %></td>
                    </tr>
                    </table> 
                    <p></p>

                    <table class="categoryTable"> <!-- Presenter Section -->
                        <tr>
                            <td>
                                <b>Presenters:</b>
                            </td>
                            <td>
                                <%# Item.Ret_Presenters %>                       
                            </td>
                        </tr>
                    </table> 
                    <p></p>
                                        
                    <table class="categoryTableDate"> <!-- Date Section -->
                        <tr>
                            <td>
                                <b>Date:</b>
                            </td>
                            <td>
                                <%# dateFormat(Item.Ret_Dates) %>                       
                            </td>
                        </tr>
                    </table> 
                    <p></p>
                    
                    <table class="categoryTable"> <!-- Time Section -->
                    <tr>
                        <td><b>Time:</b></td>
                        <td><%# Item.Ret_Checkin %></td>
                    </tr>
                    </table> 
                    <p></p>

                    <table class="categoryTable"> <!-- About/Theme: Section -->
                    <tr>
                        <td><b>About/Theme:</b></td>
                        <td><%# Item.Ret_About %></td>
                    </tr>
                    </table> 
                    <p></p>
                     
                    <table class="categoryTable"> <!-- Cost Section -->
                    <tr>
                        <td><b>Cost:</b></td>
                        <td><h4><%# Item.Ret_Cost.ToString("c") %></h4></td>
                    </tr>
                    </table> 
                    <p></p>       
                                        
                    <!-- Cart Button-->
                    <button class="myButton" name="add" type="submit" value="<%# Item.Ret_ID %>">Place Reservation</button>
                    <hr />
                </div>
            </ItemTemplate>
        </asp:Repeater>
    </div>
   
    <!-- Pagination -->
    <div class="pager">
        <%  
            Response.Write("Pages: ");
            for (int i = 1; i <= MaxPage; i++) {
                string path = RouteTable.Routes.GetVirtualPath(null, null, new RouteValueDictionary() { { "page", i } }).VirtualPath;
                string selectedCategory = (string)Page.RouteData.Values["category"] ?? Request.QueryString["category"]; // Get selected category
                
                if ((i >= 1) && (selectedCategory != null)) {
                    path = RouteTable.Routes.GetVirtualPath(null, null, new RouteValueDictionary() { { "category", selectedCategory }, {"page", i} }).VirtualPath;
                    Response.Write(string.Format("<a href='{0}' {1}>{2}</a>", path, i == CurrentPage ? "class='selected'" : "", i));
                }
                else {
                    Response.Write(string.Format("<a href='{0}' {1}>{2}</a>", path, i == CurrentPage ? "class='selected'" : "", i));   
                }
        }%>
    </div>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="SidebarContent" runat="server">
    <SS:CatLinks ID="CatLinks1" runat="server" />
</asp:Content>
